package com.zsf.controller;

import com.zsf.bean.Emp;
import com.zsf.service.Empservice;
import org.omg.CORBA.INTERNAL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @创建人 zsf
 * @创建时间 2022/12/26
 * @描述
 */
//@RestController
@Controller
//@RequestMapping("/emps")
public class EmpController {

    @Autowired
    private Empservice empservice;

    @GetMapping
    public List<Emp> getAll(){
        return empservice.queryAll();
    }

    @GetMapping("{empid}")
    public Emp queryById(@PathVariable Integer empid){
        return empservice.queryById(empid);
    }
    @PutMapping
    public Boolean update(@RequestBody Emp emp){
        return empservice.updateById(emp);
    }
    @DeleteMapping("{id}")
    public Boolean delete(@PathVariable Integer id){
        return empservice.deleteById(id);
    }
    @PostMapping
    public Boolean saveEmp(@RequestBody Emp emp){
        return empservice.saveEmp(emp);
    }

    @RequestMapping("/login.action")
    public String login(){
        return "login";
    }
}
